<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'分享员'),
);
//分享员
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['sharer_type'])){
		$params['sharer_type']=trim($_RQ['sharer_type']);
		$return['params']['sharer_type']=$_RQ['sharer_type'];
	}
	if(!empty($_RQ['order_id'])){
		$params['order_id']=trim($_RQ['order_id']);
		$return['params']['order_id']=$_RQ['order_id'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_qqdian_sharer_order',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['sharer']=pdo_get('jy_qqdian_sharer',array('openid'=>$item['sharer_openid'],'uniacid'=>$_SESSION['uniacid']));
		}
	}	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'sharer.nickname','title'=>'分享员','type'=>'string'),
			array('name'=>'order_id','title'=>'订单ID','type'=>'string'),
			array('name'=>'sharer.appid','title'=>'绑定小店ID','type'=>'string'),
			array('name'=>'share_scene','title'=>'渠道','type'=>'radio','options'=>'share_scene'),
			array('name'=>'sharer_type','title'=>'类型','type'=>'radio','options'=>'sharer_type'),
			array('name'=>'createtime','title'=>'时间','type'=>'string'),
		),'batch'=>array(
			array('type'=>'post','url'=>'/sharer.orderlist/updata/','title'=>'同步分享订单'),
		)),
		'search'=>array(
			array('name'=>'order_id','width'=>'10','title'=>'订单ID','type'=>'string'),
			array('name'=>'share_scene','width'=>'10','title'=>'渠道','type'=>'radio','options'=>'share_scene'),
		)
	);
	$return['htmls']=$htmls;
	$return['share_scene']=$this->share_scene;
	$return['sharer_type']=$this->sharer_type;
	exi($return);
}
if($_RQ['op']=='updata'){
	$this->model('sharer')->uporderlist();
	exi('同步订单成功！');
}